// @ts-ignore
import { api } from '@/utils/api';

/** 发送邮箱验证码 POST /code/sendEmailCode */
export async function codeSendEmailCode(
  body: BASE.AutoDtoWithCodeSendemailcode,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultString>;

export async function codeSendEmailCode(
  body: BASE.AutoDtoWithCodeSendemailcode,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultString>>;

export async function codeSendEmailCode(
  body: BASE.AutoDtoWithCodeSendemailcode,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultString>;

export async function codeSendEmailCode(
  body: BASE.AutoDtoWithCodeSendemailcode,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultString>(`/app/code/sendEmailCode`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultString>(`/app/code/sendEmailCode`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 发送手机验证码 POST /code/sendMobileCode */
export async function codeSendMobileCode(
  body: BASE.AutoDtoWithCodeSendmobilecode,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultString>;

export async function codeSendMobileCode(
  body: BASE.AutoDtoWithCodeSendmobilecode,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultString>>;

export async function codeSendMobileCode(
  body: BASE.AutoDtoWithCodeSendmobilecode,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultString>;

export async function codeSendMobileCode(
  body: BASE.AutoDtoWithCodeSendmobilecode,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultString>(`/app/code/sendMobileCode`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultString>(`/app/code/sendMobileCode`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}
